<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<!-- Meta, title, CSS, favicons, etc. -->
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<title>随便打TCS系统</title>
	<!-- Bootstrap -->
	<link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
		  rel="stylesheet">
	<!-- Font Awesome -->
	<link
			href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
			rel="stylesheet">
	<!-- Select2 -->
	<link href="<%=basePath%>vendors/select2/dist/css/select2.min.css"
		  rel="stylesheet">
	<!-- NProgress -->
	<link href="<%=basePath%>vendors/nprogress/nprogress.css"
		  rel="stylesheet">
	<!-- iCheck -->
	<link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
		  rel="stylesheet">

	<!-- bootstrap-progressbar -->
	<link
			href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
			rel="stylesheet">
	<!-- JQVMap -->
	<link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
		  rel="stylesheet" />
	<!-- bootstrap-daterangepicker -->
	<link
			href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
			rel="stylesheet">

	<!-- Custom Theme Style -->
	<link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">
</head>

<body class="nav-md">
<div class="container body">
	<div class="main_container">
		<div class="col-md-3 left_col">
			<div class="left_col scroll-view">
				<div class="clearfix"></div>
				<br />
			</div>
		</div>


		<!-- page content -->
		<div class="right_col" role="main">
			<div class="">
				<div class="page-title">
					<div class="title_left">
						<h3>账户信息</h3>
					</div>


				</div>
				<div class="clearfix"></div>

				<div class="row">
					<div class="col-md-12 col-sm-12 col-xs-12">
						<div class="x_panel">
							<div class="x_title">
								<h2>修改账户信息</h2>

								<div class="clearfix"></div>
							</div>
							<div class="x_content">

								<form name="myForm" class="form-horizontal form-label-left" novalidate
									  method= "post" enctype ="multipart/form-data" id="formUpload" >

									<p>
										请谨慎修改相关信息，如有修改错误请及时
										<code>联系客服</code>
										以帮助您完成相关配置
									</p>
									<span class="section">基本信息</span>

									<div class="item form-group" style="display:none">
										<label class="control-label col-md-3 col-sm-3 col-xs-12"
											   for="name">id<span class="required"></span>
										</label>
										<div class="col-md-6 col-sm-6 col-xs-12">
											<input id="id" name="id" class="form-control col-md-7 col-xs-12"
												   type="text" value="${id}">
										</div>
									</div>

									<div class="item form-group">
										<label class="control-label col-md-3 col-sm-3 col-xs-12"
											   for="name">用户手机号 <span class="required">*</span>
										</label>
										<div class="col-md-6 col-sm-6 col-xs-12">
											<input class="form-control col-md-7 col-xs-12" name="name"
												   placeholder="例如：24677111" required="required" type="text"
												   value="${mobile}" id="mobile">
										</div>
									</div>
									<div class="item form-group">
										<label class="control-label col-md-3 col-sm-3 col-xs-12"
											   for="name">登陆密码 <span class="required">*</span>
										</label>
										<div class="col-md-6 col-sm-6 col-xs-12">
											<input class="form-control col-md-7 col-xs-12" name="name"
												   placeholder="例如：24677111" required="required" type="text"
												   value="${password}" id="password">
										</div>
									</div>

									<c:if test="${adminUsergrade == 0}">
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">所属代理商 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="例如：24677111" required="required" type="text"
													   value="${parentid}" id="parentid">
											</div>
										</div>
									</c:if>
									<c:if test="${adminUsergrade == 0 || adminUsergrade == 1}">
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">所属商家 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="例如：24677111" required="required" type="text"
													   value="${shopid}" id="shopid">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">上级用户 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="例如：24677111" required="required" type="text"
													   value="${shareper}" id="shareper">
											</div>
										</div>
									</c:if>

									<div class="item form-group">
										<label class="control-label col-md-3 col-sm-3 col-xs-12"
											   for="name" >是否冻结<span
												class="required">*</span>
										</label>
										<div class="col-md-6 col-sm-6 col-xs-12">
											<select class="form-control" id="datastatus">
												<c:if test="${datastatus ==true }">
													<option value="true" selected="selected">允许</option>
													<option value="false">不允许</option>
												</c:if>
												<c:if test="${datastatus ==false }">
													<option value="true">允许</option>
													<option value="false" selected="selected">不允许</option>
												</c:if>
											</select>
										</div>
									</div>
									<c:if test="${adminUsergrade == 0 }">
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">账户余额 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="" type="text" value="" id="money">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">购物余额 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="" type="text" value="" id="shopBalance">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">话费过期时间 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="xxxx-xx-xx" type="text" value="" id="endtime">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">购物过期时间 </label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													   placeholder="xxxx-xx-xx" type="text" value="" id="shopEnddate">
											</div>
										</div>
									</c:if>
									<div class="item form-group">
										<label class="control-label col-md-3 col-sm-3 col-xs-12"
											   for="name" >调整等级<span
												class="required">*</span>
										</label>
										<div class="col-md-6 col-sm-6 col-xs-12">
											<select class="form-control" id="cbonus1level">
												<option value="-1" <c:if test="${member == -1}">selected</c:if>>无调整等级</option>
												<option value="0" <c:if test="${member == 0}">selected</c:if>>普通用户</option>
												<option value="2" <c:if test="${member == 2}">selected</c:if>>一级代理</option>
												<option value="1" <c:if test="${member == 1}">selected</c:if>>二级代理</option>
											</select>
										</div>
									</div>
									<div class="ln_solid"></div>
									<div class="form-group">
										<div class="col-md-6 col-md-offset-3">
											<a type="submit" class="btn btn-primary"
											   href="javascript:void(0)"
											   onclick="history.back(-1);">取消</a>
											<input id="revise" type="button" class="btn btn-success"
												   href="javascript:void(0)"  onclick="ajaxPost()" value="修改" >
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- /page content -->
		<!-- 上传图片并修改 -->
		<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
		<script type="text/javascript" >

		</script>

		<script type="text/javascript">
			//获取select中的选项以及value
			// ajax 对象
			function ajaxObject() {
				var xmlHttp;
				try {
					// Firefox, Opera 8.0+, Safari
					xmlHttp = new XMLHttpRequest();
				} catch (e) {
					// Internet Explorer
					try {
						xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (e) {
							alert("您的浏览器不支持AJAX！");
							return false;
						}
					}
				}
				return xmlHttp;
			}

			function getTelCheck() {
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '<%=basePath%>login/smsInfo',
					// url: 'http://shuntong.sbdznkj.com/SbdVoip/login/smsInfo',
					data: {
						Mobile: 15616565907,
						ParentId: '${adminUserId}'
					},
					success: function (data) {
						if (data.errorCode == 2000) {
							alert(data.data);
						} else{
							alert(data.data);
						}
					},
					error: function (data) {
						alert('验证失败');
					}
				});
			}

			// ajax post请求：
			function ajaxPost() {
				var id = $("#id").val();
				var password = $("#password").val();
				var money = $("#money").val();
				if (money == undefined) {
					money = "";
				}
				var parentid = $("#parentid").val();
				if (parentid == undefined) {
					parentid = "";
				}
				var shopid = $("#shopid").val();
				var mobile = $("#mobile").val();
				var shopBalance = $("#shopBalance").val();
				if (shopBalance == undefined) {
					shopBalance = "";
				}
				var endtime = $("#endtime").val();
				if (endtime == undefined) {
					endtime = "";
				}
				var shopEnddate = $("#shopEnddate").val();
				if (shopEnddate == undefined) {
					shopEnddate = "";
				}
				var achievement1 = $("#achievement1").val();
				if (achievement1 == undefined) {
					achievement1 = "";
				}
				var achievement2 = $("#achievement2").val();
				if (achievement2 == undefined) {
					achievement2 = "";
				}
				var achievement3 = $("#achievement3").val();
				if (achievement3 == undefined) {
					achievement3 = "";
				}
				var fans = $("#fans").val();
				if (fans == undefined) {
					fans = "";
				}
				var shareper = $("#shareper").val();
				var datastatus = $("#datastatus").find("option:selected").val();
				var isallprivilege = $("#isallprivilege").find("option:selected").val();
				if (isallprivilege == undefined) {
					isallprivilege = "";
				}
				var allteamreratio = $("#allteamreratio").val();
				if (allteamreratio == undefined) {
					allteamreratio = "";
				}
				var isprivilege = $("#isprivilege").find("option:selected").val();
				if (isprivilege == undefined) {
					isprivilege = "";
				}
				var teamreratio = $("#teamreratio").val();
				if (teamreratio == undefined) {
					teamreratio = "";
				}
				var iswithdraw = $("#iswithdraw").find("option:selected").val();
				if (iswithdraw == undefined) {
					iswithdraw = "";
				}
				var isbonus = $("#isbonus").find("option:selected").val();
				if (isbonus == undefined) {
					isbonus = "";
				}
				var isperformance = $("#isperformance").find("option:selected").val();
				if (isperformance == undefined) {
					isperformance = "";
				}
				var cbonus1level = $("#cbonus1level").find("option:selected").val();
				if (cbonus1level == undefined) {
					cbonus1level = "";
				}
				var cbonus2level = $("#cbonus2level").find("option:selected").val();
				if (cbonus2level == undefined) {
					cbonus2level = "";
				}
				var cbonus3level = $("#cbonus3level").find("option:selected").val();
				if (cbonus3level == undefined) {
					cbonus3level = "";
				}
				var telCheck = $("#telCheck").val();
				if (telCheck == undefined) {
					telCheck = "";
				}
				var ajax = ajaxObject();
				if(password == "" ||password == null){
					alert("密码不能为空");
				}else{
					ajax.open("post", "updateSubscribers?id=" + id +
							"&password=" + password +
							"&mobile=" + mobile +
							"&parentid=" + parentid +
							"&shopid=" + shopid +
							"&shopBalance=" + shopBalance +
							"&achievement1=" + achievement1 +
							"&achievement2=" + achievement2 +
							"&achievement3=" + achievement3 +
							"&fans=" + fans +
							"&iswithdraw=" + iswithdraw +
							"&isbonus=" + isbonus +
							"&isperformance=" + isperformance +
							"&isallprivilege=" + isallprivilege +
							"&allteamreratio=" + allteamreratio +
							"&isprivilege=" + isprivilege +
							"&teamreratio=" + teamreratio +
							"&cbonus1level=" + cbonus1level +
							"&cbonus2level=" + cbonus2level +
							"&cbonus3level=" + cbonus3level +
							"&datastatus=" + datastatus+
							"&shareper="+shareper +
							"&endtime="+endtime +
							"&shopEnddate="+shopEnddate +
							"&telCheck="+telCheck +
							"&money="+money, true);
					ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					ajax.onreadystatechange = function() {
						if (ajax.readyState == 4) {
							if (ajax.status == 200) {
								var result = ajax.responseText;
								if (result == "success") {
									//请求成功
									alert("修改成功");
									location.href = "content_yonghuguanli";
								} else {
									//请求成功
									alert(result);
									location.href = "content_yonghuguanli";
								}
							} else {
								//请求失败
								alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
							}
						} else {
						}
					};
					ajax.send();
				}
			}
		</script>
	</div>
</div>

<!-- jQuery -->
<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
<!-- bootstrap-daterangepicker -->
<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
<script
		src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- Chart.js -->
<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>
<!-- validator -->
<script src="<%=basePath%>vendors/validator/validator.js"></script>
<!-- Custom Theme Scripts -->
<script src="<%=basePath%>build/js/custom.min.js"></script>
<!-- Select2 -->
<script src="<%=basePath%>vendors/select2/dist/js/select2.full.min.js"></script>
</body>
</html>